//
//  ZXBeginView.m
//  ZXOCWeiBo
//
//  Created by mac on 15/12/2.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZXBeginView.h"

#import "ZXTabBarController.h"
#import "ZXOAuthController.h"

@implementation ZXBeginView

+(instancetype)beginView
{
    return [NSBundle loadViewFromNibName:@"ZXBeginView"];
}
/**
 *  监听开始按钮的点击事件
 */
- (IBAction)beginClick
{
    
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"access_token"] == nil)
    {
        ZXOAuthController * oauthCeontoller = [[ZXOAuthController alloc]init];
        
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:oauthCeontoller];
        //设置窗口的根控制器
        self.window.rootViewController = nav;
    }
    else
    {
        //进入主界面
        //创建主界面
        ZXTabBarController * tabBarcontr = [[ZXTabBarController alloc]init];
        
        //更改主窗口上的控制器
        [UIApplication sharedApplication].keyWindow.rootViewController = tabBarcontr;
    }
}

@end
